/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Server.domain.items;

import Server.domain.GameLevel;
import Server.domain.Player;
import Server.persistentie.ProjectileFactory;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Ripper
 */
public class RangedWeapon extends Weapon
{
    private int ammunitionType;
    //TODO
    
    public RangedWeapon(String itemName, int itemCost, int looktype, int attackValue, int defenseValue, int magicArmorValue, 
            int ammoType, boolean twoHanded, List<ItemAttribute> attributes)
    {
        super(itemName, itemCost, looktype, attackValue, defenseValue, magicArmorValue, twoHanded, attributes);
        
        setAmmunitionType(ammoType);
        //TODO
    }

    @Override
    public Item copyItem()
    {
        List<ItemAttribute> attribs = new ArrayList<ItemAttribute>();
        for(ItemAttribute ia: getEquipmentAttributes())
        {
            attribs.add(new ItemAttribute(ia.getAttribute(), ia.getAttributeValue()));
        }
        
        RangedWeapon i = new RangedWeapon(getItemName(), getItemCost(), getLooktype(), 
                getPhysicalAttackValue(), getArmorValue(), getMagicArmorValue(),
                getAmmunitionType(), isTwoHandedWeapon(), attribs);
        return i;
    }
    @Override
    public void specificAttack(GameLevel gl, Player parent) 
    {
        /*double directionOfAttack = parent.getAttackDirection();
        double x = parent.getX();
        double y = parent.getY();*/
        
        
        //TODO: create a new projectile based on ammunitionType
        gl.addProjectile(ProjectileFactory.createNewProjectile(gl, ammunitionType, parent));
    }

    public int getAmmunitionType() { return ammunitionType; }
    public final void setAmmunitionType(int ammunitionType) { this.ammunitionType = ammunitionType; }
    
    @Override
    public String getItemType()
    {
        return "ranged weapon";
    }
}
